Tree-shaking is a process in which unused portions of an application are removed (a.k.a. trimmed) from the application at deployment time. Unused portions on which other portions depend are referred to as “dependencies” of the other portions. Removing the unused portions may reduce a size of the deployed application. A variety of techniques has been proposed for removing unused portions of an application for deployment. However, each such technique has its limitations.
In one example, native compilers may statically analyze libraries linked into a single module of an application and eliminate code that is not called by the application. However, such native compilers often are incapable of handling dynamic references. Moreover, merging code into a single module may eliminate the identity of the shared module, which may hinder (e.g., prevent) the module from being shared between multiple applications and/or from being serviced outside the application.
In another example, some pre-compilers (e.g., .NET Native™) are configured to compile applications directly to native code. Such pre-compilers statically analyze the applications to determine which code is called. The pre-compilers typically merge the code into a single module in a similar manner to the native compilers mentioned above. However, unlike the native compilers, the pre-compilers often use heuristics to identify dynamic references. However, the heuristics usually are incomplete. If the heuristics fail to identify dynamic references, a developer often devotes time and resources to learn a new concept in order to communicate dynamic dependencies (rd.xml).